<?php
/*
 * Created on 2012-4-1
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
$nns_product_db = dirname(dirname ( dirname ( __FILE__ ) )); 
 require_once $nns_product_db. "/nn_cms_db/nns_products/nns_db_user_products_class.php";
 require_once $nns_product_db. "/nn_cms_db/nns_common/nns_db_constant.php";
 class nncms_controls_check_product{
 	private $user_product;
 	function nncms_controls_check_product(){
 		$this->user_product=new nns_db_user_products_class();
 	}
 	
 	public function check_product_state($nns_id,$product_type,$end_date,$vod_num,$max_num=0){
 		$state=0;
 		 switch($product_type){
                	case NNS_PRODUCT_TIME_BY_TIME:
                		if ($vod_num>1){
                			$state=1;
                		}
                	break;
                	case NNS_PRODUCT_BY_MONTH:
                		if (strtotime($end_date)<strtotime("now")){
                			$state=1;
                		}
                	
                	break;
                	case NNS_PRODUCT_BY_YEAR:
                		if (strtotime($end_date)<strtotime("now")){
                			$state=1;
                		}
                		
                	break;
                	case NNS_PRODUCT_BY_DAY:
                		if (strtotime($end_date)<strtotime("now")){
                			$state=1;
                		}
                		
                	break;
                	case NNS_PRODUCT_BY_VOD:
                	if ($max_num!=0){
                		if ($vod_num>=$max_num){
                			$state=1;
                		}
                	}
                	break;
                	
                };
                $this->user_product->nns_db_user_products_state($nns_id,$state);
                
                return $state;
 	}
 	public function __destruct() {
		$user_product=null;
	}
 }
?>
